<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>函数rest参数</title>
</head>
<script>
    //ES6引入rest参数,用于获取函数的实参,用来替代arguments
    //1、ES5获取实参的方式
    function date() {
        console.log(arguments)
    }
    date('香蕉','苹果','大白梨')
    //2、ES6 用rest参数获取实参
    function ball(...args) {
        let result = args.filter(item => item % 2 === 0)
        console.log(result)
    }
    ball(1,16,9,35,20)
    //3、rest参数放到最后
    function test(a,b,...args) {
        console.log(a,b,args)
    }
    test(1,2,34,56,23)
</script>
</html>